// components/logout-button.tsx
'use client'

import { useRouter } from 'next/navigation'
import { Button } from '@/components/ui/button'
import { authService } from '@/services/api/auth'

export function LogoutButton() {
  const router = useRouter()

  const handleLogout = async () => {
    try {
      await authService.logout()
      router.push('/login')
    } catch (error) {
      console.error(error)
    }
  }

  return (
    <Button variant="ghost" onClick={handleLogout}>
      退出登录
    </Button>
  )
}
